package com.lanyanhua.job.controller;

import com.lanyanhua.job.entity.JobLog;
import com.lanyanhua.job.entity.Result;
import com.lanyanhua.job.service.IJobLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: lanyanhua
 * @Date: 2018/11/5 0005 14:58
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/log")
public class JobLogController {


    private IJobLogService logService;
    @Autowired
    public JobLogController(IJobLogService logService) {
        this.logService = logService;
    }

    @GetMapping("/findJobLogAll")
    public Object findJobLogAll(JobLog jobLog, Integer page, Integer limit) {
        return logService.findJobLogPage(jobLog, page - 1, limit);
    }
    @PostMapping("/deleteAll")
    public Result deleteAll(){
        try {
            logService.deleteBySuccess(true);
            return new Result(true,"执行成功");
        }catch (Exception e){
            log.info("删除所有成功日志信息失败",e);
            return new Result(false,"删除日志失败");
        }
    }

}
